#ifndef __QYQ_FRAME_AT_H_
#define __QYQ_FRAME_AT_H_
#include "chip_include.h"
#ifndef __QYQ_FRAME_AT_C_
#define QYQ_FRAME_AT_EXT extern
#else
#define QYQ_FRAME_AT_EXT
#endif

// 控制参数数量
#define MODULE_ARGC_LIMIT 5

typedef int8_t (*qyq_frame_at_event_t)(unsigned int argc, const char **argv);

typedef struct
{
    uint8_t *qyq_frame_at_name;                 // AT指令名字
    uint8_t qyq_frame_at_len;                   // AT指令长度
    qyq_frame_at_event_t qyq_frame_at_test_cb;  // AT测试指令，用来显示AT指令参数的合法范围
    qyq_frame_at_event_t qyq_frame_at_query_cb; // AT查询指令，用来查询AT指令当前设置的属性
    qyq_frame_at_event_t qyq_frame_at_setup_cb; // AT设置指令，用来设置AT指令的属性（有参数）
    qyq_frame_at_event_t qyq_frame_at_exe_cb;   // AT执行指令，用来执行AT指令
} qyq_frame_at_t;

typedef struct
{
    qyq_frame_at_t *qyq_frame_at_list;
    uint8_t qyq_frame_at_list_size;

    uint8_t *qyq_frame_at_rx_buf;
    uint16_t qyq_frame_at_rx_max_size;

    uint8_t *module_argc_list;
    uint16_t module_argc_max_size;

    uint16_t qyq_frame_at_rx_timeout;
    uint16_t qyq_frame_at_index;
    uint16_t qyq_frame_at_tick;
    uint8_t qyq_frame_at_flag;

    uint16_t (*qyq_frame_at_get_tick_count)(void);
    void (*qyq_frame_at_printf)(uint8_t *buf, uint16_t len);
} qyq_frame_at_config_t;

typedef struct qyq_frame_at_type
{
    qyq_frame_at_config_t *qyq_frame_at_config;

    int8_t (*qyq_frame_at_init)(struct qyq_frame_at_type *this);
    int8_t (*qyq_frame_at_recv)(struct qyq_frame_at_type *this, uint8_t dat);
} qyq_frame_at_type_t;

QYQ_FRAME_AT_EXT int8_t qyq_frame_at_create(qyq_frame_at_type_t *this, qyq_frame_at_config_t *qyq_frame_at_config);
#endif
